package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 健康体检录入-第二页
 * 
 * @author houyuchun
 * 
 */
public class HealthExamSeventhActivity extends AbstractControlActivity
		implements OnClickListener {

	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_health_exam_seventh);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addEditTextView(R.id.edt_niaodanbai, "尿蛋白");
		addEditTextView(R.id.edt_niaotang, "尿糖");
		addEditTextView(R.id.edt_niaojiongti, "尿酮体");
		addEditTextView(R.id.edt_niaoqianxue, "尿潜血");
		addEditTextView(R.id.edt_niaochanggui_qita, "尿常规其他");
		addEditTextView(R.id.edt_kongfuxuetang, "空腹血糖");

		addRadioGroupView(R.id.rad_xindiantu, "心电图");

		addRadioEditUnionView(new int[] { R.id.edt_xindiantu_yichang }, "心电图",
				new String[] { "心电图-异常" }, R.id.rad_xindiantu, "异常");

		addEditTextView(R.id.edt_niaoweiliangbdb, "尿微量白蛋白");

		addRadioGroupView(R.id.rad_dabianqianxue, "大便潜血");

		addEditTextView(R.id.edt_tanghuaxuehongdb, "糖化血红蛋白");
		addRadioGroupView(R.id.rad_yigankangyuan, "乙型肝炎表面抗原");

		addEditTextView(R.id.edt_xueqinggbzam, "血清谷丙转氨酶");
		addEditTextView(R.id.edt_xueqinggczam, "血清谷草转氨酶");
		addEditTextView(R.id.edt_baidanbai, "白蛋白");
		addEditTextView(R.id.edt_zongdanhongsu, "总胆红素");
		addEditTextView(R.id.edt_zonghedanhongsu, "结合胆红素");
		addEditTextView(R.id.edt_xueqingjigan, "血清肌酐");
		addEditTextView(R.id.edt_xueniaosudan, "血尿素氮");
		addEditTextView(R.id.edt_xueyanongdu, "血钾浓度");
		addEditTextView(R.id.edt_xuenanongdu, "血钠浓度");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		controlManager.toControl();
		this.setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			intent.setClass(this, HealthExamSixthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_next:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			intent.setClass(this, HealthExamEighthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}

}
